package com.ruoyi.flowable.service.impl;

import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.flowable.domain.SysForm;
import com.ruoyi.flowable.mapper.SysFormMapper;
import com.ruoyi.flowable.service.ISysFormService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * 表单配置Service业务层处理
 *
 * @author heyue
 * @date 2022-04-24
 */
@Service
public class SysFormServiceImpl implements ISysFormService {
    @Autowired
    private SysFormMapper sysFormMapper;

    /**
     * 查询表单配置
     *
     * @param id 表单配置ID
     * @return 表单配置
     */
    @Override
    public SysForm selectSysFormById(Long id) {
        SysForm sysForm = sysFormMapper.selectSysFormById(id);
        return sysForm;
    }

    /**
     * 查询表单配置列表
     *
     * @param sysForm 表单配置
     * @return 表单配置
     */
    @Override
    public List<SysForm> selectSysFormList(SysForm sysForm) {
        return sysFormMapper.selectSysFormList(sysForm);
    }

    /**
     * 新增表单配置
     *
     * @param sysForm 表单配置
     * @return 结果
     */
    @Override
    public int insertSysForm(SysForm sysForm) {
        String username = SecurityUtils.getUsername();
        sysForm.setCreateBy(username);
        sysForm.setUpdateBy(username);
        sysForm.setCreateTime(new Date());
        return sysFormMapper.insertSysForm(sysForm);
    }

    /**
     * 修改表单配置
     *
     * @param sysForm 表单配置
     * @return 结果
     */
    @Override
    public int updateSysForm(SysForm sysForm) {
        String username = SecurityUtils.getUsername();
        sysForm.setUpdateBy(username);
        sysForm.setUpdateTime(new Date());
        return sysFormMapper.updateSysForm(sysForm);
    }

    /**
     * 批量删除表单配置
     *
     * @param ids 需要删除的表单配置ID
     * @return 结果
     */
    @Override
    public int deleteSysFormByIds(Long[] ids) {
        return sysFormMapper.deleteSysFormByIds(ids);
    }

    /**
     * 删除表单配置信息
     *
     * @param id 表单配置ID
     * @return 结果
     */
    @Override
    public int deleteSysFormById(Long id) {
        return sysFormMapper.deleteSysFormById(id);
    }
}
